#ifndef __CXX_VIEWS_WIDGET_EVENTS_H__
#define __CXX_VIEWS_WIDGET_EVENTS_H__

#include "viswdgtbsc.h"
#include "vismgr/view.h"

namespace viswidgets
{

#define start_event_handling(clsname) \
void clsname::on_event(view_event_type_e t, void* d) \
{ \
	switch (t) {

#define __handle_event(evtype, hdr) \
	case view_ev_##evtype: { \
		evtype ev(d); \
		hdr(ev); \
	} break;

#define end_event_handling() \
	default: break; \
	} \
}

class WIDGET_EXPORT_API event
{
public:
	event(view_event_type_e t, void* data);
	~event();

public:
	view_event_type_e type(void) {
		return m_type;
	}

protected:
	view_event_type_e m_type;
	void* m_data;

private:
	event(const event&);
	event& operator =(const event&);
};

// resize_event
class WIDGET_EXPORT_API resize_event : public event
{
public:
	resize_event(void* data);

	int original_width(void);
	int original_height(void);

private:
	void* m_data;
};

#define resize_event_downcast(ev) \
	((resize_event*)((uint)(ev) - (uint)((event*)((resize_event*)0))))

#define handle_resize_event(handler) __handle_event(resize_event, handler)

}; // namespace viswidgets
#endif	// __CXX_VIEWS_WIDGET_EVENTS_H__
/* EOF */
